package com.sanben.tag.service.impl;

import com.sanben.tag.entity.Tag;
import com.sanben.tag.mapper.TagMapper;
import com.sanben.tag.service.ITagService;
import com.sanben.tag.data.dto.TagDto;
import com.sanben.tag.data.vo.TagVo;
import com.sanben.tag.data.req.TagReq;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sanben.common.util.BeanCopyUtils;
import java.util.List;

/**
 * @author cyh
 * @description: 标签表 服务实现类
 * @date: 2020-08-18
 */
@Service
public class TagServiceImpl extends ServiceImpl<TagMapper,Tag> implements ITagService {

    @Override
    public IPage<TagVo> page(TagReq req) {
        Page<TagVo> page = new Page<>(req.getPageNum(), req.getPageSize());
        page.setRecords(this.baseMapper.page(page, req));
        return page;
    }

    @Override
    public List<Tag> lists() {
        return this.list();
    }

    @Override
    public Boolean save(TagDto dto) {
        return this.save(BeanCopyUtils.copy(dto,Tag.class));
    }

    @Override
    public Boolean updateById(TagDto dto) {
        return this.updateById(BeanCopyUtils.copy(dto,Tag.class));
    }


    @Override
    public Boolean deleteLogic(List<Integer> toIntList) {
        return  this.removeByIds(toIntList);
    }

    @Override
    public Tag detail(Integer id) {
        return this.getById(id);
    }
}
